package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TbIamge;
import com.ruoyi.system.service.ITbIamgeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 个人内容图片Controller
 * 
 * @author ruoyi
 * @date 2024-04-01
 */
@RestController
@RequestMapping("/system/iamge")
public class TbIamgeController extends BaseController
{
    @Autowired
    private ITbIamgeService tbIamgeService;

    /**
     * 查询个人内容图片列表
     */
    @PreAuthorize("@ss.hasPermi('system:iamge:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbIamge tbIamge)
    {
        startPage();
        List<TbIamge> list = tbIamgeService.selectTbIamgeList(tbIamge);
        return getDataTable(list);
    }

    /**
     * 导出个人内容图片列表
     */
    @PreAuthorize("@ss.hasPermi('system:iamge:export')")
    @Log(title = "个人内容图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbIamge tbIamge)
    {
        List<TbIamge> list = tbIamgeService.selectTbIamgeList(tbIamge);
        ExcelUtil<TbIamge> util = new ExcelUtil<TbIamge>(TbIamge.class);
        util.exportExcel(response, list, "个人内容图片数据");
    }

    /**
     * 获取个人内容图片详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:iamge:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbIamgeService.selectTbIamgeById(id));
    }

    /**
     * 新增个人内容图片
     */
    @PreAuthorize("@ss.hasPermi('system:iamge:add')")
    @Log(title = "个人内容图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbIamge tbIamge)
    {
        return toAjax(tbIamgeService.insertTbIamge(tbIamge));
    }

    /**
     * 修改个人内容图片
     */
    @PreAuthorize("@ss.hasPermi('system:iamge:edit')")
    @Log(title = "个人内容图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbIamge tbIamge)
    {
        return toAjax(tbIamgeService.updateTbIamge(tbIamge));
    }

    /**
     * 删除个人内容图片
     */
    @PreAuthorize("@ss.hasPermi('system:iamge:remove')")
    @Log(title = "个人内容图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbIamgeService.deleteTbIamgeByIds(ids));
    }
}
